//
//  MineLevelViewController.m
//  renmingongshe
//
//  Created by macbook on 2017/11/13.
//  Copyright © 2017年 xiaodian. All rights reserved.
//

#import "MineLevelViewController.h"

@interface MineLevelViewController ()<WKNavigationDelegate>
@property (strong, nonatomic) WKWebView *webView;
@end

@implementation MineLevelViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    WKWebViewConfiguration* config = [[WKWebViewConfiguration alloc]init];
    //注册js方法
    config.userContentController = [[WKUserContentController alloc]init];
    _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 70, WIDTH, HEIGHT-20) configuration:config];
    _webView.navigationDelegate = self;
    if ([self.type isEqualToString:@"user"]) {
        self.titleLabel.text = @"职称管理";
        [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?userToken=%@", API(MineUserName), [Utils getUserToken]]]]];
    }else{
        self.titleLabel.text = @"等级管理";
        [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?userToken=%@", API(MineLevel), [Utils getUserToken]]]]];
    }
    
    [self.view addSubview:_webView];
}

// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
    [self.view loadingOnAnyView];
}

// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    [self.view removeAnyView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
